const babelCore = require('@babel/core')

const code = `
    {
      function name(n) {
        return n;
      }
    }

    name("Steve");
`
const result = babelCore.transformSync(code,{
    plugins: ["@babel/plugin-transform-block-scoped-functions"]
})

console.log(result.code);